vcServoController
vcServoController is a controller for driving independent joints. The controller itself only supports forward kinematics and cannot be used in robots rather with them. For example, a servo controller can be used for external axis systems, grippers, fixtures, weld guns, and other simple mechanical structures.
See in: Overview
Module: vcRobotics
Parent: vcBehavior
Children: vcRobotController
Referenced by: vcDof.Controller, vcJoint.Controller, vcJoint.ExternalController, vcSimJointExportField.Controller
Properties
Learn how to use properties here. The properties are also inherited from the parent class.
| Name | Type | Access | Description |
| FlangeNode | vcNode | RW | Defines the flange node of servo, for example the mount plate or carriage for other kinematic structures. |
| HeartbeatTime | Real | RW | If UseHeartbeat is set to True, defines the interval or pulse for updating joints. |
| JointCount | Integer | R | Gets the number of joints in servo. |
| Joints | vcList[vcJoint] | R | Gets a list of all joints referenced by servo. |
| RootNode | vcNode | RW | Defines the root node of servo, thereby the fixed base of kinematic structure. |
| Speed | Real | RW | Defines joint speed as a percentage of maximum speed for driving joints in range 0 to 100. |
| UseHeartbeat | Boolean | RW | Turns on/off the use of a heartbeat or pulse to drive and update joints. |
Methods
Learn how to use methods here. The methods are also inherited from the parent class.
| Name | Return Type | Parameters | Description |
| calcMotionTime | Real | None | Returns the calculated motion time of servo using current joint values and listed targets. Returns: Real: motion time. |
| findJoint | vcJoint | String joint_name | Returns the first joint matching a given name in servo; otherwise returns None.See moreParameters: joint_name (String): joint name Returns: vcJoint: joint found or None |
| getJoint | vcJoint | Integer joint_index | Returns the first joint matching a given name in servo; otherwise returns None.See moreParameters: joint_name (String): joint name Returns: vcJoint: joint found or None |
| getJointTarget | Real | Integer joint_index | Returns the target value of a joint at a given index in servo.See moreParameters: joint_index (Integer): index Returns: Real: target value of a joint |
| getJointValue | Real | Integer joint_index | Returns the current value of a joint at a given index in servo.See moreParameters: joint_index (Integer): index Returns: Real: current value of a joint |
| move | vcTask | list jvalues | Drives all joints in servo to target values, and then returns the actual motion time.See moreTarget values for each joint in servo can be given as separate, optional arguments. Parameters: ([Real joint_0, ... Real joint_n]): joint values (): No arguments Returns: Real: actual motion time |
| move | vcTask | None | - |
| moveImmediate | None | List[Real] values | Drives all joints in servo to target values in zero simulation time.See moreTarget values for each joint in servo can be given as separate, optional arguments. Parameters: [Real joint_0, ... Real joint_n]: joint values |
| moveJoint | vcTask | Integer index, Real value | Moves a joint at a given index in servo to a given value, and then returns the actual motion time.See moreParameters: joint_index (Integer): index joint_value (Real): joint value Returns: Real: actual motion time |
| setJointTarget | None | Integer joint_index, Real joint_value | Sets the target value of a joint at a given index in servo to a given value. Parameters: joint_index (Integer): index joint_value (Real): joint value |
| setMotionTime | None | Real time | Forces the servo to execute joint movements at a given motion time. Parameters: time (Real): motion time |
Events
Learn how to use events here. The events are also inherited from the parent class.
| Name | Parameters | Description |
| OnHeartbeat | None | Triggered when a pulse or heartbeat is generated by servo.See moreNote: This event handler can be used by a vcRobotController object executing a vcProcessStatement object in robot program. Parameters: servo (vcServoController) event_type (vcController) |
Example: Drive Servo One Axis
""" This example shows how to set a target position for a servo joint and drive the servo to the target value.""" import vcCore as vc async def OnRun(): comp = vc.getComponent() servo_x = comp.findBehavior("ServoX") joint_index = 0 x_target = 100 servo_x.setJointTarget(joint_index,x_target) await servo_x.move()
Example: Drive Multiple Servos Asynchronously
""" This example shows how to control servos asynchronously by using the vcServoController behavior. """ import vcCore as vc async def OnRun(): comp = vc.getComponent() servo_x = comp.findBehavior("ServoX") servo_y = comp.findBehavior("ServoY") servo_z = comp.findBehavior("ServoZ") joint_index = 0 x_target = 100 y_target = 100 z_target = 100 servo_x.setJointTarget(joint_index,x_target) servo_y.setJointTarget(joint_index,y_target) servo_z.setJointTarget(joint_index,z_target) # start asynchronous motions x_motion = servo_x.move() # returns an awaitable task y_motion = servo_y.move() z_motion = servo_z.move() # wait until all motions are completed await vc.allTasks([x_motion,y_motion,z_motion]) # waits for all tasks to complete print("All servos have reached their target positions.")